package ner;

import java.io.File;

public class Controller {

	
	private InformationExtractor extractor;
	private static final String SYNTAX_INFO="Usage: java ner.Controller [filename]\n";
	private static final String INPUTFILE_NOT_FOUND = "Input file does not exists!";
	private static final String NOARGS_INFO="No arguments found!";
	
	
	public Controller(){
		
		this.extractor=new InformationExtractor();
		
	}

	public static void main(String[] args){
		
		if(args.length==0){
			System.out.println(NOARGS_INFO);
			printSyntax();
			return;
		}
		
		if(!new File(args[0]).exists()){
			System.out.println(INPUTFILE_NOT_FOUND);
			return;
		}
		
		
		Controller controller=new Controller();
		ExtractionTask task=new ExtractionTask(args[0]);
		controller.process(task);
		
	}
	
	private void process(ExtractionTask task){
		
		Knowledge.init();
		extractor.extractInfo(task);	
		printResults(task);
		
	}
	
	private void printResults(ExtractionTask task) {
		task.presentResults();
		
	}
	private static void printSyntax() {
		System.out.println(SYNTAX_INFO);
		
	}
	
	
}
